/* 
 * Copyright 2013 Sébastien Mouquet.
 * 
 * This file is part of ECovoiturage.
 * 
 * ECovoiturage is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * ECovoiturage is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Foobar. If not, see http://www.gnu.org/licenses/.
 */
package com.smouquet.ecovoiturage.core.service;

import com.smouquet.ecovoiturage.core.bean.Config;
import com.smouquet.ecovoiturage.core.exception.ConfigIOException;

/**
 * Service pour la gestion de la configuration de l'application.
 * 
 * @author sebastien.mouquet
 */
public interface ConfigService
{
    public static final String CONFIG_DIR_PROPERTY = "user.home";
    public static final String CONFIG_FILE_NAME = "ecovoiturage.properties";
    
    public static final String PROPERTY_JDBC_URL = "javax.persistence.jdbc.url";
    public static final String PROPERTY_JDBC_DRIVER = "javax.persistence.jdbc.driver";
    public static final String PROPERTY_JDBC_USER = "javax.persistence.jdbc.user";
    public static final String PROPERTY_JDBC_PASSWORD = "javax.persistence.jdbc.password";
    
    
    /**
     * @return Le chemin complet de la configuration.
     */
    String getConfigPath();
    
    /**
     * Enregistre sur le disque à l'endroit convenu ({@link ConfigService#getConfigPath()})
     * la configuration transmise en paramètre.
     * 
     * @param config Configuration à enregistrer
     * @throws ConfigIOException En cas d'erreur d'écriture de la configuration
     */
    void saveConfig(Config config) throws ConfigIOException;
    
    /**
     * Charge la configuration depuis le disque ({@link ConfigService#getConfigPath()}).
     * 
     * @return La configuration chargée
     * @throws ConfigIOException En cas d'erreur de lecture de la configuration
     */
    Config loadConfig() throws ConfigIOException;
}
